package com.alex.statistics.pojo.result.clusterAnalysis;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.util.List;

@Data
@Schema(description = "层次聚类分析结果")
public class HierarchicalClusteringResult {

    @Schema(description = "聚类合并步骤列表")
    private List<MergeStep> mergeSteps;

    @Schema(description = "最终聚类结果列表")
    private List<Cluster> finalClusters;

    @Schema(description = "计算耗时（毫秒）")
    private long computeTime;

    // 内部类：合并步骤详情
    @Data
    @Schema(description = "聚类合并步骤信息")
    public static class MergeStep {
        @Schema(description = "被合并的第一个簇ID")
        private int cluster1Id;

        @Schema(description = "被合并的第二个簇ID")
        private int cluster2Id;

        @Schema(description = "合并时的距离")
        private double distance;

        public MergeStep(int cluster1Id, int cluster2Id, double distance) {
            this.cluster1Id = cluster1Id;
            this.cluster2Id = cluster2Id;
            this.distance = distance;
        }
    }

    // 内部类：簇信息
    @Data
    @Schema(description = "聚类结果中的一个簇")
    public static class Cluster {
        @Schema(description = "簇的唯一标识ID")
        private int clusterId;

        @Schema(description = "该簇包含的原始数据点索引（对应输入data中的位置）")
        private List<Integer> pointIndices;

        public Cluster(int clusterId, List<Integer> pointIndices) {
            this.clusterId = clusterId;
            this.pointIndices = pointIndices;
        }
    }
}